/*
 * @lc app=leetcode id=187 lang=cpp
 *
 * [187] Repeated DNA Sequences
 */
class Solution {
public:
    vector<string> findRepeatedDnaSequences(string s) {
        vector<string> ret;
        int len = s.size();
        if (len <= 10) {
            return ret;
        }

        unordered_map<string, int> record;
        for (int i=0; i<=len-10; i++) {
            record[s.substr(i, 10)]++;
        }

        for (auto& it : record) {
            if (it.second > 1) {
                ret.push_back(it.first);
            }
        }
        return ret;
    }
};

